﻿'********************************************************************************
'*
'*      プラズマ着工/完了履歴　フォーム
'*
'*      File Name : frmStartCompletePlasma.vb
'*      Title     : プラズマ着工/完了履歴画面
'*      機能    　：プラズマ着工/完了履歴
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ -----------------------------------------------
' V1.0.0   2016/07/12 S.Yu         新規作成
' V2.0.0   2017/04/26 M.Maho       蘇州対応
' V3.0.0   2018/02/02 M.Sagawa     北京対応
'********************************************************************************

Imports System.Text

Public Class frmStartCompletePlasma

    '>>2018/2/2 佐川 キャリア交換対応
    '実行モード
    '0:表示 1:着工 2:製造完成 3:計上完成
    Private execMode As String = VIEW
    '<<2018/2/2 佐川 キャリア交換対応

    '外部画面呼び出しTAG
    Private Const EXEC_PG_TAG_ATLAS As String = "PL_ATLAS"

    '入力チェック用HashTable
    Dim inputCheckTable As Hashtable = New Hashtable

    'タブコントロールの設定
    Public Overrides Sub SetTabControl()
        TabPageEqp.Enabled = False
    End Sub

    '照合結果設定
    Public Overrides Sub SetPassScore()
        PASS_SCORE = 5
        ReDim m_iScore(PASS_SCORE - 1)
        ' 情報タブ「受入ラックNo1」,「受入ラックNo2」,「受入ラックNo3」,「受入ラックNo4」,「受入ラックNo5」のチェックを行う
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
    End Sub

    '照合結果クリア
    Public Overrides Sub InitualizeCollData()
        ' 情報タブ「受入ラックNo1」,「受入ラックNo2」,「受入ラックNo3」,「受入ラックNo4」,「受入ラックNo5」のチェックを行う
        ' 前工程のラックNoが空の項目はチェック済み(1)に設定する。
        If IcTag.container1.Equals("") Then
            m_iScore = {PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED}
        ElseIf IcTag.container2.Equals("") Then
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED}
        ElseIf IcTag.container3.Equals("") Then
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED}
        ElseIf IcTag.container4.Equals("") Then
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_CHECKED, PASS_SCORE_CHECKED}
        ElseIf IcTag.container5.Equals("") Then
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_CHECKED}
        Else
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
        End If
    End Sub

    'イベント設定
    Public Overrides Sub SetHandler()

        '受入ラックNo
        AddHandler txt0202.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt0203.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt0204.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt0205.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt0206.KeyPress, AddressOf beforeRackNo_KeyPress
        AddHandler txt0202.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0203.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0204.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0205.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0206.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler btnBarCode1.Click, AddressOf btnRackNo_Click
        '完了ラックNo
        AddHandler txt0502.KeyPress, AddressOf afterRackNo_KeyPress
        AddHandler txt0503.KeyPress, AddressOf afterRackNo_KeyPress
        AddHandler txt0504.KeyPress, AddressOf afterRackNo_KeyPress
        AddHandler txt0505.KeyPress, AddressOf afterRackNo_KeyPress
        AddHandler txt0506.KeyPress, AddressOf afterRackNo_KeyPress
        AddHandler txt0502.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0503.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0504.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0505.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler txt0506.LostFocus, AddressOf txtRackNo_LostFocus
        AddHandler btnBarCode2.Click, AddressOf btnRackNo_Click

        ' >> 20180710 佐川 ラックNo途入力改善
        AddHandler txt0202.Click, AddressOf rackInputFocus
        AddHandler lbl0202.Click, AddressOf rackInputFocus
        AddHandler txt0203.Click, AddressOf rackInputFocus
        AddHandler lbl0203.Click, AddressOf rackInputFocus
        AddHandler txt0204.Click, AddressOf rackInputFocus
        AddHandler lbl0204.Click, AddressOf rackInputFocus
        AddHandler txt0205.Click, AddressOf rackInputFocus
        AddHandler lbl0205.Click, AddressOf rackInputFocus
        AddHandler txt0206.Click, AddressOf rackInputFocus
        AddHandler lbl0206.Click, AddressOf rackInputFocus

        AddHandler lbl0502.Click, AddressOf afterRackInputFocus
        AddHandler txt0502.Click, AddressOf afterRackInputFocus
        AddHandler lbl0503.Click, AddressOf afterRackInputFocus
        AddHandler txt0503.Click, AddressOf afterRackInputFocus
        AddHandler lbl0504.Click, AddressOf afterRackInputFocus
        AddHandler txt0504.Click, AddressOf afterRackInputFocus
        AddHandler lbl0505.Click, AddressOf afterRackInputFocus
        AddHandler txt0505.Click, AddressOf afterRackInputFocus
        AddHandler lbl0506.Click, AddressOf afterRackInputFocus
        AddHandler txt0506.Click, AddressOf afterRackInputFocus
        ' << 20180710 佐川 ラックNo途入力改善

    End Sub

    'Lot Noでデータベースからデータを取得する
    Public Overrides Sub GetDataByIcTag()

        '初期化
        InputDataClear()

        'ICタグのデータで画面を設定する
        SetFromTag()

        'ロット部のセット
        setGridViewLot()

        If String.IsNullOrEmpty(IcTag.szUID) Then
            IcTag = LastTag
        End If

        '製造条件取得
        setJyokenData()

        '>> 20180309 大賀 計上完成後のICTAG初期化によりExceptionが発生するため初期化位置を変更
        '前工程チェック処理用HashTable初期化
        inputCheckTable = New Hashtable
        Dim addCount As Integer = 1
        inputCheckTable.Add(CStr(addCount), IcTag.container1)
        addCount += 1

        'container2が空文字以外の場合はHashTableに追加する。
        If Not IcTag.container2.Equals("") Then
            inputCheckTable.Add(CStr(addCount), IcTag.container2)
            addCount += 1
        End If

        'container3が空文字以外の場合はHashTableに追加する。
        If Not IcTag.container3.Equals("") Then
            inputCheckTable.Add(CStr(addCount), IcTag.container3)
            addCount += 1
        End If

        'container4が空文字以外の場合はHashTableに追加する。
        If Not IcTag.container4.Equals("") Then
            inputCheckTable.Add(CStr(addCount), IcTag.container4)
            addCount += 1
        End If

        'container5が空文字以外の場合はHashTableに追加する。
        If Not IcTag.container5.Equals("") Then
            inputCheckTable.Add(CStr(addCount), IcTag.container5)
            addCount += 1
        End If
        '<< 20180309 大賀 計上完成後のICTAG初期化によりExceptionが発生するため初期化位置を変更

        '工程明細テーブル取得
        setDetailData()
        If IcTag.Status = TagProcessStatus.Processing Then
            htRackNo = New Hashtable
            rackNoCnt = 0
        End If
        For Each dr In dtDetailData.Rows
            If dr("MNF_CND_TAG").Equals(lbl0200.Tag) Then
                If dr("SEQ") = 1 Then
                    'ラックNo.1
                    txt0202.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                ElseIf dr("SEQ") = 2 Then
                    'ラックNo.2
                    txt0203.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                ElseIf dr("SEQ") = 3 Then
                    'ラックNo.3
                    txt0204.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                ElseIf dr("SEQ") = 4 Then
                    'ラックNo.4
                    txt0205.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                ElseIf dr("SEQ") = 5 Then
                    'ラックNo.5
                    txt0206.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/11/1
                End If
            End If
        Next

        '工程ヘッダーテーブル取得
        getHeadData()

        'ヘッダーの設定
        With m_dtMat
            If .Rows.Count > 0 Then
                '着完日時
                DisplayDate()
            Else
                If m_dtMat.Columns.Count > 0 Then
                    .Rows.Add()
                Else
                    .Columns.Add("BEGIN_TIME")
                    .Rows.Add()
                End If
            End If
        End With
    End Sub

    '初期化、背景色の設定
    Public Sub InputDataClear()

        '>>2018/2/2 佐川 キャリア交換対応
        execMode = VIEW
        '<<2018/2/2 佐川 キャリア交換対応

        '受入ラックNo
        txt0202.Text = String.Empty
        txt0203.Text = String.Empty
        txt0204.Text = String.Empty
        txt0205.Text = String.Empty
        txt0206.Text = String.Empty
        txt0202.BackColor = NORMAL_INIT_COLOR
        lbl0202.BackColor = NORMAL_INIT_COLOR
        txt0203.BackColor = NORMAL_INIT_COLOR
        lbl0203.BackColor = NORMAL_INIT_COLOR
        txt0204.BackColor = NORMAL_INIT_COLOR
        lbl0204.BackColor = NORMAL_INIT_COLOR
        txt0205.BackColor = NORMAL_INIT_COLOR
        lbl0205.BackColor = NORMAL_INIT_COLOR
        txt0206.BackColor = NORMAL_INIT_COLOR
        lbl0206.BackColor = NORMAL_INIT_COLOR
        btnBarCode1.Enabled = False

        '完了ラックNo
        txt0502.Text = String.Empty
        txt0503.Text = String.Empty
        txt0504.Text = String.Empty
        txt0505.Text = String.Empty
        txt0506.Text = String.Empty
        txt0502.BackColor = NORMAL_INIT_COLOR
        lbl0502.BackColor = NORMAL_INIT_COLOR
        txt0503.BackColor = NORMAL_INIT_COLOR
        lbl0503.BackColor = NORMAL_INIT_COLOR
        txt0504.BackColor = NORMAL_INIT_COLOR
        lbl0504.BackColor = NORMAL_INIT_COLOR
        txt0505.BackColor = NORMAL_INIT_COLOR
        lbl0505.BackColor = NORMAL_INIT_COLOR
        txt0506.BackColor = NORMAL_INIT_COLOR
        lbl0506.BackColor = NORMAL_INIT_COLOR
        btnBarCode2.Enabled = False

    End Sub

    '画面データ保存（着工時）
    Public Overrides Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean

        '>>2018/2/2 佐川 キャリア交換対応
        execMode = BEGIN
        '<<2018/2/2 佐川 キャリア交換対応

        If saveDetail(BEGIN) < 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    '画面データ保存（製造完成）
    Public Overrides Function SaveCompleteInfo(Optional ByVal status As ProcessStatus = ProcessStatus.ManufComplete) As Integer

        '>>2018/2/2 佐川 キャリア交換対応
        execMode = COMPLETE
        '<<2018/2/2 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(COMPLETE)
    End Function

    '画面データ保存（計上完成）
    Public Overrides Function SaveTotalInfo() As Integer

        '>>2018/2/2 佐川 キャリア交換対応
        execMode = TOTAL
        '<<2018/2/2 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(TOTAL)
    End Function

    '工程明細テーブル更新処理
    Private Function saveDetail(ByVal type As String) As Integer
        setLotData()
        Dim rowsCnt As Integer = dtDBUpd.Rows.Count
        Dim addIndex As Integer = 0

        '受入ラックNo1
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 1
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0202.Text
        addIndex += 1

        '受入ラックNo2
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 2
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0203.Text
        addIndex += 1

        '受入ラックNo3
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 3
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0204.Text
        addIndex += 1

        '受入ラックNo4
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 4
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0205.Text
        addIndex += 1

        '受入ラックNo5
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 5
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0206.Text
        addIndex += 1

        If type <> BEGIN Then
            '完了ラックNo1
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0500.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 1
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0502.Text
            addIndex += 1

            '完了ラックNo2
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0500.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 2
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0503.Text
            addIndex += 1

            '完了ラックNo3
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0500.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 3
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0504.Text
            addIndex += 1

            '完了ラックNo4
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0500.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 4
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0505.Text
            addIndex += 1

            '完了ラックNo5
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0500.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 5
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0506.Text
        End If

        Return m_cEquipMat.SaveDetail(lotNo, IcTag.szProcsCD, type,
                                  m_szTable, dtDBUpd, m_dtHeader,
                                  m_cIdohyo.EquipInfo.szEquipNo, serverTime)
    End Function

    Public Overrides Function EndCheck() As Boolean
        Dim CheckFlag As Boolean

        '完了ラックNoの空白チェック
        CheckFlag = checkBlank(txt0502.Text, lbl0500.Text.Replace(vbCrLf, ""))
        checkColor(txt0502, CheckFlag, lbl0502.Name)
        If Not CheckFlag Then
            Return False
        End If

        ' ラックNoの重複チェック
        ' 空白の場合は重複チェックを行わず，それ以上のラックNo入力がないものとする
        If Not String.IsNullOrEmpty(txt0502.Text) Then
            If Not chkRackNo(txt0502, lbl0502) Then
                Return False
            End If
            If Not String.IsNullOrEmpty(txt0503.Text) Then
                If Not chkRackNo(txt0503, lbl0503) Then
                    Return False
                End If
                If Not String.IsNullOrEmpty(txt0504.Text) Then
                    If Not chkRackNo(txt0504, lbl0504) Then
                        Return False
                    End If
                    If Not String.IsNullOrEmpty(txt0505.Text) Then
                        If Not chkRackNo(txt0505, lbl0505) Then
                            Return False
                        End If
                        If Not String.IsNullOrEmpty(txt0506.Text) Then
                            If Not chkRackNo(txt0506, lbl0506) Then
                                Return False
                            End If
                        End If
                    End If
                End If
            End If
        End If

        '前工程一致チェック
        '空白の場合は前工程一致チェックを行わず，それ以上のラックNo入力がないものとする
        If Not String.IsNullOrEmpty(txt0502.Text) Then
            If txt0502.Text.Equals(txt0202.Text) Or txt0502.Text.Equals(txt0203.Text) Or
                txt0502.Text.Equals(txt0204.Text) Or txt0502.Text.Equals(txt0205.Text) Or txt0502.Text.Equals(txt0206.Text) Then
                MsgBox(getMsgStr("MSG10018", txt0502.Text))
                checkColor(txt0502, False, txt0502.Text)
                Return False
            End If
            If Not String.IsNullOrEmpty(txt0503.Text) Then
                If txt0503.Text.Equals(txt0202.Text) Or txt0503.Text.Equals(txt0203.Text) Or
                    txt0503.Text.Equals(txt0204.Text) Or txt0503.Text.Equals(txt0205.Text) Or txt0503.Text.Equals(txt0206.Text) Then
                    MsgBox(getMsgStr("MSG10018", txt0503.Text))
                    checkColor(txt0503, False, txt0503.Text)
                    Return False
                End If
                If Not String.IsNullOrEmpty(txt0504.Text) Then
                    If txt0504.Text.Equals(txt0202.Text) Or txt0504.Text.Equals(txt0203.Text) Or
                        txt0504.Text.Equals(txt0204.Text) Or txt0504.Text.Equals(txt0205.Text) Or txt0504.Text.Equals(txt0206.Text) Then
                        MsgBox(getMsgStr("MSG10018", txt0504.Text))
                        checkColor(txt0504, False, txt0504.Text)
                        Return False
                    End If
                    If Not String.IsNullOrEmpty(txt0505.Text) Then
                        If txt0505.Text.Equals(txt0202.Text) Or txt0505.Text.Equals(txt0203.Text) Or
                            txt0505.Text.Equals(txt0204.Text) Or txt0505.Text.Equals(txt0205.Text) Or txt0505.Text.Equals(txt0206.Text) Then
                            MsgBox(getMsgStr("MSG10018", txt0505.Text))
                            checkColor(txt0505, False, txt0505.Text)
                            Return False
                        End If
                        If Not String.IsNullOrEmpty(txt0506.Text) Then
                            If txt0506.Text.Equals(txt0202.Text) Or txt0506.Text.Equals(txt0203.Text) Or
                                txt0506.Text.Equals(txt0204.Text) Or txt0506.Text.Equals(txt0205.Text) Or txt0506.Text.Equals(txt0206.Text) Then
                                MsgBox(getMsgStr("MSG10018", txt0506.Text))
                                checkColor(txt0506, False, txt0506.Text)
                                Return False
                            End If
                        End If
                    End If
                End If
            End If
        End If

        Return True
    End Function

    Public Overrides Sub ConfScreenItem()
        If txtLotNo.TextLength > 0 Then
            If IcTag.Status = TagProcessStatus.Ready Then
                '着工待ち
                btnBarCode1.Enabled = True
                btnBarCode2.Enabled = False
                txt0202.BackColor = BARCODE_INIT_COLOR
                lbl0202.BackColor = BARCODE_INIT_COLOR
                txt0203.BackColor = BARCODE_INIT_COLOR
                lbl0203.BackColor = BARCODE_INIT_COLOR
                txt0204.BackColor = BARCODE_INIT_COLOR
                lbl0204.BackColor = BARCODE_INIT_COLOR
                txt0205.BackColor = BARCODE_INIT_COLOR
                lbl0205.BackColor = BARCODE_INIT_COLOR
                txt0206.BackColor = BARCODE_INIT_COLOR
                lbl0206.BackColor = BARCODE_INIT_COLOR
                txt0502.BackColor = NORMAL_INIT_COLOR
                lbl0502.BackColor = NORMAL_INIT_COLOR
                txt0503.BackColor = NORMAL_INIT_COLOR
                lbl0503.BackColor = NORMAL_INIT_COLOR
                txt0504.BackColor = NORMAL_INIT_COLOR
                lbl0504.BackColor = NORMAL_INIT_COLOR
                txt0505.BackColor = NORMAL_INIT_COLOR
                lbl0505.BackColor = NORMAL_INIT_COLOR
                txt0506.BackColor = NORMAL_INIT_COLOR
                lbl0506.BackColor = NORMAL_INIT_COLOR
            Else
                '着工中
                btnBarCode1.Enabled = False
                btnBarCode2.Enabled = True
                txt0202.BackColor = NORMAL_INIT_COLOR
                lbl0202.BackColor = NORMAL_INIT_COLOR
                txt0203.BackColor = NORMAL_INIT_COLOR
                lbl0203.BackColor = NORMAL_INIT_COLOR
                txt0204.BackColor = NORMAL_INIT_COLOR
                lbl0204.BackColor = NORMAL_INIT_COLOR
                txt0205.BackColor = NORMAL_INIT_COLOR
                lbl0205.BackColor = NORMAL_INIT_COLOR
                txt0206.BackColor = NORMAL_INIT_COLOR
                lbl0206.BackColor = NORMAL_INIT_COLOR
                txt0502.BackColor = BARCODE_INIT_COLOR
                lbl0502.BackColor = BARCODE_INIT_COLOR
                txt0503.BackColor = BARCODE_INIT_COLOR
                lbl0503.BackColor = BARCODE_INIT_COLOR
                txt0504.BackColor = BARCODE_INIT_COLOR
                lbl0504.BackColor = BARCODE_INIT_COLOR
                txt0505.BackColor = BARCODE_INIT_COLOR
                lbl0505.BackColor = BARCODE_INIT_COLOR
                txt0506.BackColor = BARCODE_INIT_COLOR
                lbl0506.BackColor = BARCODE_INIT_COLOR
            End If

        End If

    End Sub

    '受入ラックNo入力処理
    Private Sub beforeRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox) 'Add 苗 2018/4/10
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            '入力チェックを行う
            beforeRackNoCheck(sender, e)
        End If
    End Sub

    '受入ラックNoの入力値と前工程の整合性確認
    Private Sub beforeRackNoCheck(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
        Dim idx As Integer = CInt(txtData.Name.ToString.Substring(5, 2)) - 2
        Dim preConsRackNo As String = String.Empty
        Dim procCheckResult As Boolean = False
        Dim preRackNoCount As Double = 0


        'ラックNo1のみ空白チェックを行う
        If txtData.Name.Equals("txt0202") Then
            If txtData.Text.Equals("") Then
                MsgBox(getMsgStr("MSG00020", lbl0200.Text))
                checkColor(sender, False, lblData.Name)
                m_iScore(idx) = PASS_SCORE_WAIT_CHECK
                Exit Sub
            End If
        End If

        Dim rackSameFlg As Boolean = False
        If Not txtData.Text.Equals("") Then
            'ラックNo重複チェック
            If Not chkRackNo(txtData, lblData) Then
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.Enabled = True
                txtData.Focus()
                txtData.SelectAll()
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If

            '前工程との比較
            For i = 1 To inputCheckTable.Count()
                ' 前工程のラックNoと一致する場合
                If inputCheckTable(CStr(i)).Equals(txtData.Text) Then
                    rackSameFlg = True
                    m_iScore(idx) = PASS_SCORE_CHECKED '2018/2/22 佐川 ラックNo入力動作を統一
                    Exit For
                End If
            Next
        Else
            rackSameFlg = True
        End If

        '>>20180313 大賀 搬送容器桁数チェックを共通化
        ' ラックNoの桁数チェック
        If Not isCheckCaseLength(txtData, RACK_CASE_NO_LENGTH, lblData) Then
            m_iScore(idx) = PASS_SCORE_WAIT_CHECK
            Exit Sub
        End If
        '<<20180313 大賀 搬送容器桁数チェックを共通化

        '前工程と一致しない場合はエラーを表示する
        If Not rackSameFlg Then
            MsgBox(getMsgStr("MSG00052", lbl0200.Text))
            checkColor(sender, False, lblData.Name)
            m_iScore(idx) = PASS_SCORE_WAIT_CHECK
            txtData.SelectAll() '2018/2/22 佐川 ラックNo入力動作を統一
            Exit Sub
            '>> 2018/2/22 佐川 ラックNo入力動作を統一
        Else
            If inputCheckTable.Count() = CInt(txtData.Name.ToString.Substring(5, 2)) - 1 Then
                txtData.Enabled = False
                CheckCollScore()
                Exit Sub
            End If
            '<< 2018/2/22 佐川 ラックNo入力動作を統一
        End If

        'フォーカス変更
        For i = 2 To 6
            If txtData.Name = String.Format("txt{0}0{1}", txtData.Tag.ToString, i) Then
                lblData = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i), False)(0)

                txtData.BackColor = ENTERED_INIT_COLOR
                lblData.BackColor = ENTERED_INIT_COLOR
                txtData.Enabled = False

                '5列目以下だったらフォーカスを移す
                If i < 6 Then
                    Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)
                    Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)

                    nextTxtData.Enabled = True
                    nextTxtData.Focus()
                    nextTxtData.SelectAll()
                    nextTxtData.BackColor = Color.Cyan
                    nextLbl.BackColor = Color.Cyan
                End If
            End If
        Next
        'm_iScore(idx) = PASS_SCORE_CHECKED '2018/2/22 佐川 ラックNo入力動作を統一
        'CheckCollScore() '2018/2/22 佐川 ラックNo入力動作を統一
    End Sub

    '完了ラックNo入力処理
    Private Sub afterRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox) 'Add 苗 2018/4/10
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            '入力チェックを行う
            afterRackNoCheck(sender, e)
        End If
    End Sub

    '完了ラックNoの入力値と前工程の整合性確認
    Private Sub afterRackNoCheck(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
        Dim idx As Integer = CInt(txtData.Name.ToString.Substring(5, 2)) - 2
        Dim preConsRackNo As String = String.Empty
        Dim procCheckResult As Boolean = False
        Dim preRackNoCount As Double = 0

        'ラックNo1のみ空白チェックを行う
        If txtData.Name.Equals("txt0502") Then
            If txtData.Text.Equals("") Then
                MsgBox(getMsgStr("MSG00020", lbl0200.Text))
                checkColor(sender, False, lblData.Name)
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.Enabled = True
                txtData.Focus()
                txtData.SelectAll()
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If
        End If

        If Not txtData.Text.Equals("") Then
            'ラックNo重複チェック
            If Not chkRackNo(txtData, lblData) Then
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.Enabled = True
                txtData.Focus()
                txtData.SelectAll()
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If

            '受入ラック相関チェック
            If txtData.Text.Equals(txt0202.Text) Or txtData.Text.Equals(txt0203.Text) Or
            txtData.Text.Equals(txt0204.Text) Or txtData.Text.Equals(txt0205.Text) Or txtData.Text.Equals(txt0206.Text) Then
                MsgBox(getMsgStr("MSG10018", txtData.Text))
                checkColor(sender, False, lblData.Name)
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.Enabled = True
                txtData.Focus()
                txtData.SelectAll()
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If

            '>>20180313 大賀 搬送容器桁数チェックを共通化
            ' ラックNoの桁数チェック
            If Not isCheckCaseLength(txtData, RACK_CASE_NO_LENGTH, lblData) Then
                Exit Sub
            End If
            '<<20180313 大賀 搬送容器桁数チェックを共通化

            ''<<2018/2/23 佐川 RSB確認結果一覧No90
            'If txtData.Text.Length > RACK_CASE_NO_LENGTH Then
            '    MsgBox(getMsgStr("MSG00001", lbl0500.Text))
            '    txtData.Enabled = True
            '    txtData.Focus()
            '    txtData.SelectAll()
            '    '>> 2018/2/23 佐川 エラー時に赤色に変更
            '    txtData.BackColor = ERROR_INIT_COLOR
            '    lblData.BackColor = ERROR_INIT_COLOR
            '    '<< 2018/2/23 佐川 エラー時に赤色に変更
            '    Exit Sub
            'End If
            ''<<2018/2/23 佐川 RSB確認結果一覧No90
        End If

        'フォーカス変更
        For i = 2 To 6
            If txtData.Name = String.Format("txt{0}0{1}", txtData.Tag.ToString, i) Then
                lblData = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i), False)(0)

                txtData.BackColor = ENTERED_INIT_COLOR
                lblData.BackColor = ENTERED_INIT_COLOR
                txtData.Enabled = False

                '5列目以下だったらフォーカスを移す
                If i < 6 Then
                    Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)
                    Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0}0{1}", txtData.Tag.ToString, i + 1), False)(0)

                    nextTxtData.Enabled = True
                    nextTxtData.Focus()
                    nextTxtData.SelectAll()
                    nextTxtData.BackColor = Color.Cyan
                    nextLbl.BackColor = Color.Cyan
                End If
            End If
        Next
    End Sub

    '計上完成正常時の画面初期化
    Protected Overrides Sub initializForm()
        MyBase.initializForm()
        InputDataClear()
    End Sub

    '受入ラックNoタブキー対応
    Private Sub beforeRackNo_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles _
        txt0202.PreviewKeyDown, txt0203.PreviewKeyDown, txt0204.PreviewKeyDown, txt0205.PreviewKeyDown, txt0206.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            beforeRackNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '完了ラックNoタブキー対応
    Private Sub afterRackNo_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles _
        txt0502.PreviewKeyDown, txt0503.PreviewKeyDown, txt0504.PreviewKeyDown, txt0505.PreviewKeyDown, txt0506.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            afterRackNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '>>2018/2/2 佐川 キャリア交換対応
    'IcTag保存内容設定
    Protected Overrides Sub icTagDataSet()
        '製造完成、計上完成時は画面入力値の値を設定する。
        If execMode.Equals(COMPLETE) Or execMode.Equals(TOTAL) Then
            IcTag.container1 = txt0502.Text
            IcTag.container2 = txt0503.Text
            IcTag.container3 = txt0504.Text
            IcTag.container4 = txt0505.Text
            IcTag.container5 = txt0506.Text
        Else
            '初期値をそのまま保存するため、変更しない。
        End If
    End Sub
    '<<2018/2/2 佐川 キャリア交換対応

    ' >> 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する
    ''' <summary>
    ''' 作業者入力後のフォーカスを各画面で設定する
    ''' 各画面でオーバーライドされない場合はTabIndex順に移動する
    ''' </summary>
    ''' <param name="inputType">作業者入力タイプ</param>
    ''' <param name="nowControl">対象コントロール</param>
    Protected Overrides Sub setNextFocus(ByVal inputType As OPERATER_INPUT_TYPE, ByVal nowControl As Control)
        If m_ProcessStatus <> ProcessStatus.Ready Then  ' ロット未入力の場合は処理しない
            If IcTag.Status = TagProcessStatus.Ready Then   ' 未着工
                If inputType = OPERATER_INPUT_TYPE.START_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt0202.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCode1.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.Processing Then  ' 着工中
                If inputType = OPERATER_INPUT_TYPE.END_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt0502.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCode2.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.ManufComplete Then ' 製造完成

            End If
        End If
        ' 各画面個別のフォーカスに移動しない場合は次のTabIndexに移動
        SelectNextControl(nowControl, True, True, True, True)
    End Sub
    ' << 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する

    ' >> 20180710 佐川 ラックNo途入力改善
    Public Overrides Sub rackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '未着工のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Ready Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub

    Public Sub afterRackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '着工中のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Processing Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub
    ' << 20180710 佐川 ラックNo途入力改善

    Public Overrides Sub updateRackInfo()
        Dim rackNo As New ArrayList
        Dim dbLot As New clsDbLotDefect
        If txt0502.Text <> "" Then
            rackNo.Add(txt0502.Text)
        End If
        If txt0503.Text <> "" Then
            rackNo.Add(txt0503.Text)
        End If
        If txt0504.Text <> "" Then
            rackNo.Add(txt0504.Text)
        End If
        If txt0505.Text <> "" Then
            rackNo.Add(txt0505.Text)
        End If
        If txt0506.Text <> "" Then
            rackNo.Add(txt0506.Text)
        End If
        dbLot.DelInsRackInfo(IcTag.szLotNo, rackNo)
    End Sub
End Class
